<?php

declare(strict_types=1);

namespace App\Overwrites;

use Hyperf\Contract\LengthAwarePaginatorInterface;
use Hyperf\Paginator\LengthAwarePaginator;
use Mine\Annotation\DependProxy;

#[DependProxy(values: [LengthAwarePaginatorInterface::class])]
class ApiPaginator extends LengthAwarePaginator
{
    public function toArray(): array
    {
        return [
            'list' => $this->items->toArray(),
            'count' => $this->total(),
            'current_page' => $this->currentPage(),
            'per_page' => $this->perPage(),
            'last_page' => $this->lastPage(),
            'from' => $this->firstItem(),
            'to' => $this->lastItem(),
        ];
    }
}
